package com.five.sbgroup5job.service.impl;
//21330174048马静
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.five.sbgroup5job.entity.Sale;
import com.five.sbgroup5job.service.SaleService;
import com.five.sbgroup5job.mapper.SaleMapper;
import com.five.sbgroup5job.vo.SaleVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
* @author hujinru
* @description 针对表【sale】的数据库操作Service实现
* @createDate 2024-11-08 11:13:10
*/
@Service
public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale>
    implements SaleService {
    @Resource
    private SaleMapper saleMapper;


    @Override
    public List<Sale> salelist() {
        return saleMapper.selectList(null);
    }


    @Override
    public String saleAdd(SaleVo saleVo) {
        Sale sale = new Sale();
        sale.setName(saleVo.getName());
        sale.setPhone(saleVo.getPhone());
        sale.setAddress(saleVo.getName());
        sale.setMenu(saleVo.getMenu());
        sale.setQuantity(saleVo.getQuantity());
        sale.setPrice(saleVo.getPrice());
        sale.setTotal(saleVo.getTotal());
        sale.setTime(new Date());
        int result = saleMapper.insert(sale);
        if (result >0) {
            return "添加成功";
        }else {
            return "添加失败";
        }
    }
    @Override
    public String saleUpdate(SaleVo saleVo) {
        Sale sale = new Sale();
        sale.setUserId(4l);
        sale.setName("鹭卓");
        int result = saleMapper.updateById(sale);
        if (result > 0) {
           return "修改成功";
        } else {
            return "修改失败";
        }

    }
    //删除
    @Override
    public String saleDelete(SaleVo saleVo) {
        int result = saleMapper.deleteById(4l);
        if (result > 0) {
            return "删除成功";
        } else {
            return "删除失败";
        }
    }




}




